import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:personinfo/router/Route.dart';
import 'package:personinfo/states/appController.dart';
import 'package:personinfo/utils/Interceptor.dart';
import 'package:personinfo/utils/OrientationController.dart';
import 'package:personinfo/widgets/mainWidget/BottomWidget.dart';
import 'package:shared_preferences/shared_preferences.dart';

//入口函数
void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await SharedPreferences.getInstance(); // 预热
  Get.put<AppController>(AppController()); // onInit 会自动调用
  // 设置全局竖屏
  OrientationController.lockPortrait();
  runApp(const MyApp());

}

class MyApp extends StatefulWidget {
  const MyApp({super.key});
  @override
  State<StatefulWidget> createState()=> _MyApp();
}

class _MyApp extends State<MyApp>{

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return  MaterialApp(
        initialRoute:'/splash',//初始化加载的路由
        onGenerateRoute: AppRouter.generateRoute,
        debugShowCheckedModeBanner: false,
        home: const BottomWidget(),
        navigatorObservers: [Interceptor()],
        theme: ThemeData(
          colorScheme: ColorScheme.fromSeed(
              seedColor: Colors.purple,
              brightness: Brightness.light
          ),
          pageTransitionsTheme: const PageTransitionsTheme(
              builders: {
                TargetPlatform.android:CupertinoPageTransitionsBuilder(),
                TargetPlatform.iOS:CupertinoPageTransitionsBuilder()
              }
          ),
          bottomNavigationBarTheme: const BottomNavigationBarThemeData(
              unselectedItemColor: Colors.black87,
              unselectedIconTheme: IconThemeData(color: Colors.black87)
          ),

        ),
    );
  }
}





